package com.mpgame.database.redis.config;

import com.mpgame.database.constants.Constants;

import lombok.Data;

@Data
public class RedisCfg {
    private String host = "localhost";
    private int port = 6379;
    private String password = null;
    private int database = 0;
    private int timeout = 2000;
    private int maxTotal = 100;
    private int maxIdle = 10;
    private int minIdle = 5;
    private long maxWaitMillis = 1000L;
    private boolean testOnBorrow = true;
    private boolean testOnReturn = true;
    private boolean testWhileIdle = true;

    private int commandTimeout = 2000;
    private boolean shutdownTimeout = true;
    private int shutdownQuietPeriod = 100;
    private int shutdownTimeoutMs = 100;

    public static RedisCfg getDefault(){
        RedisCfg config = new RedisCfg();
        config.setHost("127.0.0.1");
        config.setPort(Constants.CRedis.REDIS_PORT);
        config.setPassword(Constants.CRedis.REDIS_PWD);
        config.setDatabase(0);
        config.setMaxTotal(100);
        config.setMaxIdle(10);
        config.setMinIdle(5);
        config.setMaxWaitMillis(1000L);
        config.setTestOnBorrow(true);
        config.setTestOnReturn(true);
        config.setTestWhileIdle(true);
        config.setCommandTimeout(2000);
        return config;
    }
}
